package engine.core
{
	import engine.asset.*;
	import flash.net.*;
	
	public class RxRecord
	{
		private static var s_fileName:String;
		private static var s_record:XML = null;
		private static var s_frame:int;
		private static var s_playback:Array = null;
		private static var s_playbackIndex:int;
		private static var s_deltaTime:Number;
		
		public function RxRecord()
		{
		}
		
		public static function UpdateForRecord(param1:Number) : void
		{
			var _loc_2:String = null;
			var _loc_3:XML = null;
			if (s_record != null)
			{
				_loc_2 = "<frame dt=\"" + param1 + "\" ";
				_loc_2 = _loc_2 + ("x=\"" + RxMouse.x + "\" ");
				_loc_2 = _loc_2 + ("y=\"" + RxMouse.y + "\" ");
				_loc_2 = _loc_2 + ("lc=\"" + int(RxMouse.leftClicked) + "\" ");
				_loc_2 = _loc_2 + ("ld=\"" + int(RxMouse.leftDown) + "\" ");
				_loc_2 = _loc_2 + ("k1=\"" + int(RxKeyboard.isDown(RxKeyboard.KEY_1)) + "\" ");
				_loc_2 = _loc_2 + ("k2=\"" + int(RxKeyboard.isDown(RxKeyboard.KEY_2)) + "\" ");
				_loc_2 = _loc_2 + ("k3=\"" + int(RxKeyboard.isDown(RxKeyboard.KEY_3)) + "\" ");
				_loc_2 = _loc_2 + ("k4=\"" + int(RxKeyboard.isDown(RxKeyboard.KEY_4)) + "\" ");
				_loc_2 = _loc_2 + ("k5=\"" + int(RxKeyboard.isDown(RxKeyboard.KEY_5)) + "\" ");
				_loc_2 = _loc_2 + ("k6=\"" + int(RxKeyboard.isDown(RxKeyboard.KEY_6)) + "\" ");
				_loc_2 = _loc_2 + "/>";
				_loc_3 = new XML(_loc_2);
				s_record.appendChild(_loc_3);
				if (s_frame >= 60)
				{
					Save();
					s_frame = s_frame - 60;
				}
				var _loc_5:* = s_frame + 1;
				s_frame = _loc_5;
			}
		}
		
		private static function Save() : void
		{
			var _so:* = SharedObject.getLocal(s_fileName);
			var flushStatus:String;
			_so.data.layout = s_record.toXMLString();
			try
			{
				flushStatus = _so.flush(10000);
			}
			catch (error:Error)
			{
			}
		}
		
		public static function InitializeForRecord(param1:String) : void
		{
			s_fileName = param1;
			s_record = new XML("<record>\n</record>");
			s_frame = 0;
		}
		
		public static function InitializeForPlayback(param1:String) : void
		{
			var _loc_4:XML = null;
			var _loc_2:* = RxAssetXML.GetByURL(param1);
			var _loc_3:* = _loc_2.GetXML();
			s_playback = new Array();
			for each (_loc_4 in _loc_3.frame)
			{
				
				s_playback.push(_loc_4);
			}
			s_playbackIndex = 0;
		}
	}
}